﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Class01
{
    class Class02
    {
        static void Main(string[] args)
        {

            Student st = new Student();
            st.Name = "战士";
            st.Age = 8;
            st.Sex = "男";
            st.Introduce();

            //test1();
            //test2();
            //test3();
            //test4();
            //test5();
            //test6();

        }
        public static void test1()
        {

            //*****
            //*****
            //****
            //*****
            //*****



            Console.WriteLine("请输入正方形的边长：");
            int a = Convert.ToInt32(Console.ReadLine());
            for (int i = 0; i < 5; i++)
            {
                for (int j = 0; j < 5; j++)
                {
                    Console.Write("*");
                }
                Console.WriteLine(" ");
            }
            Console.ReadLine();


            Console.WriteLine("请输入正方形的边长：");
            int b = Convert.ToInt32(Console.ReadLine());
            string[,] arr = new string[b, b];
            for (int m = 0; m < arr.GetLength(0); m++)
            {
                for (int k = 0; k < arr.GetLength(1); k++)
                {
                    arr[m, k] = "*";
                }
            }

            for (int m = 0; m < arr.GetLength(0); m++)
            {
                for (int k = 0; k < arr.GetLength(1); k++)
                {
                    Console.Write(arr[m, k]);
                }
                Console.WriteLine("");
            }


        }
        public static void test2()
        {

            string[,] arr = new string[10, 10];
            for (int m = 1; m < arr.GetLength(0); m++)
            {
                for (int k = 1; k <= m; k++)
                {
                    arr[m, k] = m + "*" + k + "=" + m * k + " ";
                }
            }

            for (int m = 0; m < arr.GetLength(0); m++)
            {
                for (int k = 0; k < arr.GetLength(1); k++)
                {
                    Console.Write(arr[m, k]);
                }
                Console.WriteLine("");
            }



            //1 * 1 = 1
            //2 * 1 = 2   2 * 2 = 4
            //3 * 1 = 3   3 * 2 = 6   3 * 3 = 9
            //4 * 1 = 4   4 * 2 = 8   4 * 3 = 12  4 * 4 = 16
            //5 * 1 = 5   5 * 2 = 10  5 * 3 = 15  5 * 4 = 20  5 * 5 = 25
            //6 * 1 = 6   6 * 2 = 12  6 * 3 = 18  6 * 4 = 24  6 * 5 = 30  6 * 6 = 36
            //7 * 1 = 7   7 * 2 = 14  7 * 3 = 21  7 * 4 = 28  7 * 5 = 35  7 * 6 = 42  7 * 7 = 49
            //8 * 1 = 8   8 * 2 = 16  8 * 3 = 24  8 * 4 = 32  8 * 5 = 40  8 * 6 = 48  8 * 7 = 56  8 * 8 = 64
            //9 * 1 = 9   9 * 2 = 18  9 * 3 = 27  9 * 4 = 36  9 * 5 = 45  9 * 6 = 54  9 * 7 = 63  9 * 8 = 72  9 * 9 = 81
            for (int i = 1; i < 10; i++)
            {
                for (int j = 1; j <= i; j++)
                {
                    Console.Write(i + "*" + j + "=" + (i * j) + " ");

                }
                Console.WriteLine();
            }
            Console.ReadLine();

        }
        public static void test3()
        {
            Console.WriteLine("请输入正方形的边长：");
            int a = Convert.ToInt32(Console.ReadLine());
            for (int i = 0; i < 5; i++)
            {
                for (int j = 0; j < 5; j++)
                {
                    if (i == 0 || i == 4)
                    {
                        Console.Write("*");
                    }
                    else
                    {
                        if (j == 0 || j == 4)
                        {
                            Console.Write("*");
                        }
                        else
                        {
                            Console.Write(" ");
                        }
                    }
                }

                Console.WriteLine(" ");
            }
            Console.ReadLine();



            Console.WriteLine("请输入正方形的边长：");
            int b = Convert.ToInt32(Console.ReadLine());
            string[,] arr = new string[b, b];
            for (int m = 0; m < arr.GetLength(0); m++)
            {
                for (int k = 0; k < arr.GetLength(1); k++)
                {
                    if (m == 0 || m == a - 1)
                    {
                        arr[m, k] = "*";
                    }
                    else
                    {
                        if (k == 0 || k == a - 1)
                        {
                            arr[m, k] = "*";

                        }
                        else
                        {
                            arr[m, k] = " ";
                        }
                    }
                }
            }
            for (int m = 0; m < arr.GetLength(0); m++)
            {
                for (int k = 0; k < arr.GetLength(1); k++)
                {
                    Console.Write(arr[m, k]);
                }
                Console.WriteLine("");
            }
        }
        public static void test4()
        {
           
            string[,] arr = new string[5,5];
            for (int i = 0; i < arr.GetLength(0); i++)
            {
                for (int k = 0; k < arr.GetLength(1); k++)
                {
                    if (i== 0||i== arr.GetLength(0)-1)
                    {
                        if (k == (arr.GetLength(1)-1)/2)
                        {
                            arr[i, k] = "*";
                        }
                        else {
                            arr[i, k] = " ";
                        }
                      
                    }
                    if (i== (arr.GetLength(0) - 1) / 2 -1|| i== (arr.GetLength(0) - 1) / 2+1)
                    {
                        if (k== (arr.GetLength(1) - 1) / 2 -1|| k== (arr.GetLength(1) - 1) / 2 || k== (arr.GetLength(1) - 1) / 2+1)
                        {
                            arr[i, k] = "*";
                        }
                        else
                        {
                            arr[i, k] = " ";
                        }
                    
                    }
                    if (i== (arr.GetLength(0) - 1) / 2)
                    {
                        arr[i, k] = "*";
                    }
                    
                    
                }

            }

            for (int m = 0; m < arr.GetLength(0); m++)
            {
                for (int k = 0; k < arr.GetLength(1); k++)
                {
                    Console.Write(arr[m, k]);
                }
                Console.WriteLine("");
            }
        }
        public static void test5()
        {

            Console.WriteLine("请输入杨辉三角行数：");
            int b = Convert.ToInt32(Console.ReadLine());
            int[,] arr = new int[b, b];
            for (int i = 0; i < arr.GetLength(0); i++)
            {
                for (int k = 0; k <= i; k++)
                {
                    if (k == 0 || k == i)
                    {
                        arr[i, k] = 1;
                    }
                    else
                    {
                        arr[i, k] = arr[i - 1, k - 1] + arr[i - 1, k];
                    }
                }
            }
            for (int m = 0; m < arr.GetLength(0); m++)
            {
                for (int n = 0; n <= m; n++)
                {
                    Console.Write(arr[m, n] + "\t");
                }
                Console.WriteLine();
            }
        }
        public static void test6()
        {
            int[] arr = { 5, 1, 4, 8, 7 };
            for (int i = 0; i < arr.Length; i++)
            {
                if (i % 2 == 0)
                {
                    Console.WriteLine(arr[i]);
                }
            }
        }
    }
}
    



   

